<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib uri="/WEB-INF/quik_function.tld" prefix="qu"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>
	<head>
		<meta http-equiv="Content-Type" content="text /html; charset=utf-8">
		<title>咨客_结帐</title>
		<link href="<c:url value="/resources/css/style.css" />" rel="stylesheet" type="text/css">
		<link href="<c:url value="/resources/css/default/easyui.css" />" rel="stylesheet" type="text/css">
		<link href="<c:url value="/resources/css/icon.css" />" rel="stylesheet" type="text/css">
		<script type="text/javascript" src="<c:url value="/resources/js/jquery-1.7.2.js" />"></script>
		<script type="text/javascript" src="<c:url value="/resources/js/util.js" />"></script>
		<script type="text/javascript" src="<c:url value="/resources/js/zDialog/zDrag.js" />"></script>
		<script type="text/javascript" src="<c:url value="/resources/js/zDialog/zDialog.js" />"></script>
		<script type="text/javascript">
			var memberFlag = false;  //验证会员信息标志
			var cardAmount = 0;
			var opFlag = 0;
			
			//授权
			function onAuth(){
				//验证
				if($.trim($("#actualAmount").val()) == ''){
					$.messager.alert('警告', "请填写应收金额!");
					return false;
				}
				
				//会员金额验证
				if($("#paymentType").val() == 'memberCard'){
					if(!memberFlag){
						$.messager.alert('警告', "请输入会员卡验证!");
						return false;
					}
					if(parseInt(cardAmount) - parseInt($("#receiveFeeHid").val()) < 0){
					 	$.messager.alert('警告', "会员卡余额不足，请选择其它方式!");
						return false;
					}
				}
				
				//判断是否需要密码授权
				$("#operatePass").val('');
				$("#operateAccount").val('');
				
				if(opFlag > 0){
					var diag = new Dialog();
					diag.Width = 300;
					diag.Height = 110;
					diag.Drag=false;
					diag.Title = "授权操作";
					diag.InvokeElementId = "passwordDiv";
					diag.OKEvent = function(){
						if($id("operatePass").value == '' || $id("operateAccount").value == ''){
							Dialog.alert("请授权!");
							return false;
						}
						diag.close();
						onPay();
					};
					diag.show();
				}else{
					onPay();
				}
			}
			
			//结帐
			function onPay(){
				var serviceSize = $("#serviceSize").val();
				var chessSize = $("#chessSize").val();
				var otherSize = $("#otherSize").val();
				var billingItems = "";  //格式:module;itemId;isFree;isDiscount;discountRange;actualPrice;
				var flag = false;
				var subItems = "";
				
				//组合数据
				if(opFlag > 0){ //确定有折扣或赠送，组合数据上传以便进行二次批价，并保存相关的折扣及赠送信息
					if(serviceSize > 0){						
						for(var i = 0; i < serviceSize; i ++){							
							subItems = "service;" + $("#id_service" + i).val() + ";";
							flag = false;
							if($("#giveServiceBox" + i).attr("checked") != "undefined" && $("#giveServiceBox" + i).attr("checked") == "checked"){
								subItems += "Y;";
								flag = true;
							}else
								subItems += "N;";
							if($("#discountServiceBox" + i).attr("checked") != "undefined" && $("#discountServiceBox" + i).attr("checked") == "checked"){
								subItems += "Y;" + $("#discountRange_service" + i).numberbox('getValue') + ";";
								flag = true;
							}else
								subItems += "N;100;";
							subItems += $("#actualPrice_service" + i).val() + ",";
							if(flag)
								billingItems += subItems;
						}
					}
				
					if(chessSize > 0){
						for(var i = 0; i < chessSize; i ++){
							flag = false;
							subItems = "chess;" + $("#id_chess" + i).val() + ";";
							if($("#giveChessBox" + i).attr("checked") != "undefined" && $("#giveChessBox" + i).attr("checked") == "checked"){
								subItems += "Y;";
								flag = true;
							}else
								subItems += "N;";
							if($("#discountChessBox" + i).attr("checked") != "undefined" && $("#discountChessBox" + i).attr("checked") == "checked"){
								subItems += "Y;" + $("#discountRange_chess" + i).numberbox('getValue') + ";";
								flag = true;
							}else
								subItems += "N;100;";
							subItems += $("#actualPrice_chess" + i).val() + ",";
							if(flag)
								billingItems += subItems;
						}
					}
					
					if(otherSize > 0){
						for(var i = 0; i < otherSize; i ++){
							flag = false;
							subItems = "other;" + $("#id_other" + i).val() + ";";
							if($("#giveOtherBox" + i).attr("checked") != "undefined" && $("#giveOtherBox" + i).attr("checked") == "checked"){
								subItems += "Y;";
								flag = true;
							}else
								subItems += "N;";
							if($("#discountOtherBox" + i).attr("checked") != "undefined" && $("#discountOtherBox" + i).attr("checked") == "checked"){
								subItems += "Y;" + $("#discountRange_other" + i).numberbox('getValue') + ";";
								flag = true;
							}else
								subItems += "N;100;";
							subItems += $("#actualPrice_other" + i).val() + ",";
							if(flag)
								billingItems += subItems;
						}
					}
					billingItems = billingItems.substr(0, billingItems.length - 1);
				}
				$.ajax({
					url:'pay',
					data:{'paymentType':$("#paymentType").val(),
						  'totalPrice':'${totalPrice.totalPrice}',
						  'vipPrice':'${totalPrice.vipPrice}',
						  'receivePrice':$("#receiveFeeHid").val(),
						  'actualAmount':moneyFormat($("#actualAmount").numberbox('getValue')),
						  'returnAmount':moneyFormat($("#returnAmount").val()),
						  'vipCard':$.trim($("#vipCard").val()),
						  'billingItems':billingItems,
						  'billingIds':$("#billingIds").val()}, 
					type:'post',
					dataType:'text',
					async:false,
					cache:false,
					success:function(data){
						if(data == "success"){
							$.messager.alert('操作结果', "付款成功!");
							$("#payBtn").attr("disabled", true);
						}else
							$.messager.alert('操作结果', data);
					}
					
				});
				
			}
			
			//付款方式选择
			function onSelect(value){
				if(value == "cash"){
					$("#actualAmount").attr("readonly", false);
					$("#actualAmount").numberbox('setValue', "");
					$("#returnAmount").val("");
				}else if(value == "card"){
					$("#actualAmount").attr("readonly", true);
					$('#actualAmount').numberbox('setValue', $("#receive").val());
					$("#returnAmount").val("0.00");
				}else if(value == "memberCard"){
					$("#actualAmount").attr("readonly", true);
					$('#actualAmount').numberbox('setValue', $("#receive").val());
					$("#returnAmount").val("0.00");
				}
			}
			
			//验证会员卡号
			function onMember(){
				$.ajax({
					url:'checkMember',
					data:{'vipCard':$.trim($("#vipCard").val())}, 
					type:'post',
					dataType:'json',
					async:false,
					cache:false,
					success:function(data){
						if(data.result == "success"){
							$("#memberName").val(data.obj.client_name);
							$("#currVipAmount").val(numFormat(data.obj.curr_vip_amount));
							cardAmount = data.obj.curr_vip_amount;
							$("#errorInfo").html("");
							memberFlag = true;
							
							//应实收修改为会员价
							$("#receive").val($("#vipFee").val());
				 			$("#receiveFeeHid").val('${totalPrice.vipPrice}');
				 			
				 			if($("#paymentType").val() != 'cash'){
				 				$('#actualAmount').numberbox('setValue', $("#receive").val());
								$("#actualAmount").attr("readonly", true);
								$("#returnAmount").val("0.00");
				 			}else{
				 				$("#actualAmount").val("");
								$("#actualAmount").attr("readonly", false);
								$("#returnAmount").val("");
				 			}
						}else{
							$("#errorInfo").html("<font color='red'>" + data.result + "</font>");
						}
					}
				});
			}
			
			//赠送计算实际价格
			function onGive(module, index, ckbox){
				var fee = 0, receiveFee = 0;
				if(ckbox.checked){
				    //检查打折是否选中，如果打折选中，去掉打折操作
				    if($("#discount" + toHeadUpperCase(module) + "Box" + index).attr("checked") != "undefined" && $("#discount" + toHeadUpperCase(module) + "Box" + index).attr("checked") == "checked"){
				    	$("#discount" + toHeadUpperCase(module) + "Box" + index).attr("checked", false);
				    	 opFlag -= 1;
				    	//不允许打折，恢复
						$("#discountRange_" + module + index).attr("readonly", true);
						$("#discountRange_" + module + index).numberbox('setValue', "100");
						
						//计算打折
						fee = parseInt($("#discountFeeHid").val()) - parseInt($("#totalPrice_" + module + index).val()) + parseInt($("#actualPrice_" + module + index).val()) ;
						$("#discountFee").val(numFormat(fee));
						$("#discountFeeHid").val(fee);
						
						//计算应收
						 receiveFee = parseInt('${totalPrice.totalPrice}') - fee;
						$("#receive").val(numFormat(receiveFee));
						$("#receiveFeeHid").val(receiveFee);
						
						if($("#paymentType").val() != 'cash'){
							 $("#actualAmount").val($("#receive").val());
							 $("#returnAmount").val("0.00");
						 }
						
						$("#actual_" + module + index).html(numFormat($("#totalPrice_" + module + index).val()));
						$("#actualPrice_" + module + index).val($("#totalPrice_" + module + index).val());
				    }
				    
				    fee = parseInt($("#discountFeeHid").val()) + parseInt($("#actualPrice_" + module + index).val());
				    
				    $("#actual_" + module + index).html("0.00");
					$("#actualPrice_" + module + index).val(0);
				    
				    opFlag += 1;//标志赋值
				    
				}else{
					$("#actual_" + module + index).html(numFormat($("#totalPrice_" + module + index).val()));
					$("#actualPrice_" + module + index).val($("#totalPrice_" + module + index).val());
					
					fee = parseInt($("#discountFeeHid").val()) - parseInt($("#actualPrice_" + module + index).val());
					
					opFlag -= 1;//标志赋值
				}
				 receiveFee = parseInt('${totalPrice.totalPrice}') - fee;
				
			     $("#discountFee").val(numFormat(fee));
				 $("#discountFeeHid").val(fee);
				 
				 $("#receive").val(numFormat(receiveFee));
				 $("#receiveFeeHid").val(receiveFee);
				 
				 if($("#paymentType").val() != 'cash'){
					 $("#actualAmount").val($("#receive").val());
					 $("#returnAmount").val("0.00");
				 }
			}
			
			//<input type="hidden" name="actualHid_service${status.index}"  id="actualHid_service${status.index}" value="${service.actualPrice}">
			//打折计算实际价格
			function onDiscount(module, index, ckbox){
				var fee = 0, receiveFee = 0;
				if(ckbox.checked){
					 if($("#give" + toHeadUpperCase(module) + "Box" + index).attr("checked") != "undefined" && $("#give" + toHeadUpperCase(module) + "Box" + index).attr("checked") == "checked"){
					    $("#give" + toHeadUpperCase(module) + "Box" + index).attr("checked", false);
					    $("#actual_" + module + index).html(numFormat($("#totalPrice_" + module + index).val()));
						
						fee = parseInt($("#discountFeeHid").val()) - parseInt($("#actualPrice_" + module + index).val());
						
						opFlag -= 1;//标志赋值
						
						receiveFee = parseInt('${totalPrice.totalPrice}') - fee;
							
					    $("#discountFee").val(numFormat(fee));
						$("#discountFeeHid").val(fee);
						 
						$("#receive").val(numFormat(receiveFee));
						$("#receiveFeeHid").val(receiveFee);
						 
						if($("#paymentType").val() != 'cash'){
						    $("#actualAmount").val($("#receive").val());
							$("#returnAmount").val("0.00");
						}
					 }
					
					$("#discountRange_" + module + index).attr("readonly", false);
					
					opFlag += 1;//赠送/打折标志赋值
				}else{
					opFlag -= 1;//赠送/打折标志赋值
					
					//不允许打折，恢复
					$("#discountRange_" + module + index).attr("readonly", true);
					$("#discountRange_" + module + index).numberbox('setValue', "100");
					
					//计算打折
					fee = parseInt($("#discountFeeHid").val()) - parseInt($("#totalPrice_" + module + index).val()) + parseInt($("#actualPrice_" + module + index).val()) ;
					$("#discountFee").val(numFormat(fee));
					$("#discountFeeHid").val(fee);
					
					//计算应收
					 receiveFee = parseInt('${totalPrice.totalPrice}') - fee;
					$("#receive").val(numFormat(receiveFee));
					$("#receiveFeeHid").val(receiveFee);
					
					if($("#paymentType").val() != 'cash'){
						 $("#actualAmount").val($("#receive").val());
						 $("#returnAmount").val("0.00");
					 }
					
					$("#actual_" + module + index).html(numFormat($("#totalPrice_" + module + index).val()));
					$("#actualPrice_" + module + index).val($("#totalPrice_" + module + index).val());
				}
			}
			
			//检查输入的折扣是否满足最低折扣的要求
			function onDiscountCheck(module, index, value, srcRange){
				if(parseInt(value) > 100 || parseInt(value) < srcRange){
					$.messager.alert('警告', "折扣范围不合法!");
					$("#discountRange_" + module + index).numberbox('setValue', "100");
					return false;
				}
				
				var fee = 0, receiveFee = 0;
				var discountFee = parseInt($("#totalPrice_" + module + index).val()) * parseInt(value)/100;
				
				var srcFee = $("#actualPrice_" + module + index).val();

				$("#actualPrice_" + module + index).val(discountFee);	
				$("#actual_" + module + index).html(numFormat($("#actualPrice_" + module + index).val()));

				//计算打折
				fee = parseInt($("#discountFeeHid").val()) - parseInt($("#actualPrice_" + module + index).val()) + parseInt(srcFee);
				$("#discountFee").val(numFormat(fee));
				$("#discountFeeHid").val(fee);
				
				//计算应收
				 receiveFee = parseInt('${totalPrice.totalPrice}') - fee;
				$("#receive").val(numFormat(receiveFee));
				$("#receiveFeeHid").val(receiveFee);
				
				if($("#paymentType").val() != 'cash'){
					$("#actualAmount").val($("#receive").val());
					$("#returnAmount").val("0.00");
				}
			}
			
			//计算找零
			function onReturnAmount(value){
				var actualAmount = moneyFormat(value);
				var returnAmount = parseInt(actualAmount) - parseInt($("#receiveFeeHid").val());
				if(returnAmount < 0){
					$.messager.alert('警告', "应收金额不足!");
					return false;
				}				
				
				$("#returnAmount").val(numFormat(returnAmount));
			}
		</script>
	</head>
	
	<body>
		<c:import url="/WEB-INF/resources/common/consult_header.jsp" />
		
		<h1>结帐</h1>
		
		<div style="float:left; width:1000px;margin-right: 15px;">
			
				<div style="width:400px; text-align: right;"><span id="infoSPAN">
					<c:if test="${!payAuthFlag}">
						<font color="red">未完成操作项，无法结帐</font>
					</c:if>
				</span></div>
			
			<table width="1000px;">
				<tr>
					<td width="200px;" style="height: 100px;">
						<fieldset style="height:110px;width:200px;">
							<legend>折扣、赠送金额</legend>
								&nbsp;&nbsp;&nbsp;&nbsp;
								总费用：<input type="text" name="totalFee" id="totalFee" size="20px;" readonly value="${qu:parsePrice(totalPrice.totalPrice)}"/> <br/>
								折扣/赠送：<input type="text" name="discountFee" id="discountFee" size="20px;" value="0.00" style="margin-top: 5px;" readonly/><br/>
								          <input type="hidden" name="discountFeeHid" id="discountFeeHid" value="0" />
								&nbsp;&nbsp;&nbsp;&nbsp;
								会员价：<input type="text" name="vipFee" id="vipFee" size="20px;" style="margin-top: 5px;" readonly value="${qu:parsePrice(totalPrice.vipPrice)}" /> <br/>
						</fieldset>
					</td>
				
					<td width="250px;" style="height:100px;">
						<fieldset style="height:110px;width:250px;">
							<legend>实收金额</legend>
								付款方式：<select style="width:120px;" name="paymentType" id="paymentType" onchange="onSelect(this.value);">
											<c:forEach var="code" items="${paymentTypeList}">
												<option value="${code.code}">${code.name}</option>	
											</c:forEach>
										 </select> <br/>
								&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
								应收：<input type="text" name="receive" id="receive" size="20px;" readonly style="margin-top: 5px;" value="${qu:parsePrice(totalPrice.actualPrice)}" /> <br />
									  <input type="hidden" name="receiveFeeHid" id="receiveFeeHid" value="${totalPrice.actualPrice}" />
								&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
								实收：<input name="actualAmount" id="actualAmount" size="20px;" class="easyui-numberbox" style="margin-top: 5px;"  
											data-options="precision:2, onChange:function(value){onReturnAmount(value);}" /> <br />
								&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
								找零：<input type="text" name="returnAmount" id="returnAmount" size="20px;" style="margin-top: 5px;" readonly />
						</fieldset>
					</td>
					
					<td id="memberTD" width="300px;" style="height: 100px;">
						<fieldset style="height:110px;width:300px;">
							<legend>会员卡</legend>
								会员卡号：<input type="text" name="vipCard" id="vipCard" size="20px;"/>
								&nbsp;<input type="button" name="memberBtn" id="memberBtn" value="验证" onclick="onMember();" /> 
								<br />
								&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
								姓名：<input type="text" name="memberName" id="memberName" size="20px;" style="margin-top: 5px;" readonly/> <br />
								&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
								余额：<input type="text" name="currVipAmount" id="currVipAmount" size="20px;" style="margin-top: 5px;" readonly/> <br />
								<span id="errorInfo" style="width:300px;margin-left: 90px; margin-top: 10px;"></span>
						</fieldset>
					</td>
				</tr>
			</table>
			<br/>
			<input type="button" name="payBtn" style="margin-left: 450px;" id="payBtn" value="结帐" onclick="onAuth()" <c:if test="${!payAuthFlag}">disabled</c:if>  />
			<br/>
			<fieldset style="width:1000px;">
				<legend>消费明细</legend>
				<table style="border-collapse: collapse;width:1000px;text-align: center;">
					<tr>
						<th style="border: 1px solid #7F9DB9;font-weight: bold;">手牌号</th>
						<th style="border: 1px solid #7F9DB9;font-weight: bold;">房间号</th>
						<th style="border: 1px solid #7F9DB9;font-weight: bold;">项目名称</th>
						<th style="border: 1px solid #7F9DB9;font-weight: bold;">单位</th>
						<th style="border: 1px solid #7F9DB9;font-weight: bold;">数量</th>
						<th style="border: 1px solid #7F9DB9;font-weight: bold;">折扣</th>						
						<th style="border: 1px solid #7F9DB9;font-weight: bold;">单价</th>
						<th style="border: 1px solid #7F9DB9;font-weight: bold;">总格</th>
						<th style="border: 1px solid #7F9DB9;font-weight: bold;">会员价</th>
						<th style="border: 1px solid #7F9DB9;font-weight: bold;">实际价</th>
						<th style="border: 1px solid #7F9DB9;font-weight: bold;">技师</th>
						<th style="border: 1px solid #7F9DB9;font-weight: bold;">状态</th>
						<th style="border: 1px solid #7F9DB9;font-weight: bold;">开始时间</th>
						<th style="border: 1px solid #7F9DB9;font-weight: bold;">结束时间</th>
						<th style="border: 1px solid #7F9DB9;font-weight: bold;">是否赠送</th>
						<th style="border: 1px solid #7F9DB9;font-weight: bold;">是否折扣</th>
					</tr>
					
					<c:if test="${fn:length(serviceList) >= 0}">
					<c:forEach var="service" items="${serviceList}" varStatus="status">
						<tr>
						<td style="border: 1px solid #7F9DB9;">${service.tokenNo}</td>
						<td style="border: 1px solid #7F9DB9;">${service.roomNo}</td>
						<td style="border: 1px solid #7F9DB9;">${service.productName}</td>
						<td style="border: 1px solid #7F9DB9;">${service.unit}</td>
						<td style="border: 1px solid #7F9DB9;">${service.qty}</td>
						<td style="border: 1px solid #7F9DB9;">
							<c:choose>
								<c:when test="${service.if_able_discount == able and service.status != 'cancel'}">
									<input type="text" name="discountRange_service${status.index}" id="discountRange_service${status.index}" value="100"  
										class="easyui-numberbox" readonly data-options="onChange:function(value){
												onDiscountCheck('service', ${status.index}, value, '${service.discount_range}');
											}"/>
									<input type="text" name="rangeHidden_service${status.index }" id="rangeHidden_service${status.index}" value="${service.discount_range}" />
								</c:when>
								<c:otherwise>100</c:otherwise>
							</c:choose>
						</td>						
						<td style="border: 1px solid #7F9DB9;">${qu:parsePrice(service.price)}</td>
						<td style="border: 1px solid #7F9DB9;">${qu:parsePrice(service.totalPrice)}</td>
						<td style="border: 1px solid #7F9DB9;">${qu:parsePrice(service.vipPrice)}</td>
						<td style="border: 1px solid #7F9DB9;"><span id="actual_service${status.index}">${qu:parsePrice(service.actualPrice)}</span></td>
						<td style="border: 1px solid #7F9DB9;">${service.workerNo}</td>
						<td style="border: 1px solid #7F9DB9;">${service.statusName}</td>
						<td style="border: 1px solid #7F9DB9;">${service.startTime}</td>
						<td style="border: 1px solid #7F9DB9;">${service.endTime}</td>
						<td style="border: 1px solid #7F9DB9;">
							<c:if test="${service.status != 'cancel' }">
								<c:if test="${service.if_able_gift == able}">
									<input type="checkbox" name="giveServiceBox${status.index}" value="service_${status.index}" id="giveServiceBox${status.index}" onchange="onGive('service', ${status.index}, this)"/>
								</c:if>
							</c:if>
						</td>
						<td style="border: 1px solid #7F9DB9;">
							<c:if test="${service.status != 'cancel' }">
								<c:if test="${service.if_able_discount == able}">
									<input type="checkbox" name="discountServiceBox${status.index}" value="service_${status.index}" id="discountServiceBox${status.index}" onchange="onDiscount('service', ${status.index}, this)"/>
								</c:if>
							</c:if>
							<input type="hidden" name="id_service${status.index}"  id="id_service${status.index}" value="${service.id}">
							<input type="hidden" name="actualPrice_service${status.index}"  id="actualPrice_service${status.index}" value="${service.actualPrice}">
							<input type="hidden" name="totalPrice_service${status.index}"  id="totalPrice_service${status.index}" value="${service.totalPrice}">
							<input type="hidden" name="vipPrice_service${status.index}"  id="vipPrice_service${status.index}" value="${service.vipPrice}">
						</td>
					</tr>
					</c:forEach>
					</c:if>
					
					<!-- 棋牌 -->
					<c:if test="${fn:length(chessList) >= 0}">
					<c:forEach var="chess" items="${chessList}" varStatus="status">
						<tr>
						<td style="border: 1px solid #7F9DB9;">${chess.tokenNo}</td>
						<td style="border: 1px solid #7F9DB9;">${chess.roomNo}</td>
						<td style="border: 1px solid #7F9DB9;">${chess.productName}</td>
						<td style="border: 1px solid #7F9DB9;">${chess.unit}</td>
						<td style="border: 1px solid #7F9DB9;">${chess.qty}</td>
						<td style="border: 1px solid #7F9DB9;">
							<c:choose>
								<c:when test="${chess.if_able_discount == able and chess.status != 'cancel'}">
									<input type="text" name="discountRange_chess${status.index}"  size="3" id="discountRange_chess${status.index}" value="100" 
											class="easyui-numberbox" readonly data-options="onChange:function(value){
												onDiscountCheck('chess', ${status.index}, value, '${chess.discount_range}');
											}"/>
									<input type="hidden" name="rangeHidden_chess${status.index }" id="rangeHidden_chess${status.index}" value="${chess.discount_range}" />
								</c:when>
								<c:otherwise>100</c:otherwise>
							</c:choose>
						</td>						
						<td style="border: 1px solid #7F9DB9;">${qu:parsePrice(chess.price)}</td>
						<td style="border: 1px solid #7F9DB9;">${qu:parsePrice(chess.totalPrice)}</td>
						<td style="border: 1px solid #7F9DB9;">${qu:parsePrice(chess.vipPrice)}</td>
						<td style="border: 1px solid #7F9DB9;"><span id="actual_chess${status.index}">${qu:parsePrice(chess.actualPrice)}</span></td>
						<td style="border: 1px solid #7F9DB9;">&nbsp;</td>
						<td style="border: 1px solid #7F9DB9;">${chess.statusName}</td>
						<td style="border: 1px solid #7F9DB9;">${chess.startTime}</td>
						<td style="border: 1px solid #7F9DB9;">${chess.endTime}</td>
						<td style="border: 1px solid #7F9DB9;">
							<c:if test="${chess.status != 'cancel' }">
								<c:if test="${chess.if_able_gift == able}">
									<input type="checkbox" name="giveChessBox${status.index}" id="giveChessBox${status.index}" value="chess_${status.index}" onchange="onGive('chess', ${status.index}, this);" />
								</c:if>
							</c:if>
						</td>
						<td style="border: 1px solid #7F9DB9;">
							<c:if test="${chess.status != 'cancel' }">
								<c:if test="${chess.if_able_discount == able}">
									<input type="checkbox" name="discountChessBox${status.index}" id="discountChessBox${status.index}" value="chess_${status.index}" onchange="onDiscount('chess', ${status.index}, this)"/>
								</c:if>
							</c:if>
							<input type="hidden" name="id_chess${status.index}"  id="id_chess${status.index}" value="${chess.id}">
							<input type="hidden" name="actualPrice_chess${status.index}"  id="actualPrice_chess${status.index}" value="${chess.actualPrice}">
							<input type="hidden" name="totalPrice_chess${status.index}"  id="totalPrice_chess${status.index}" value="${chess.totalPrice}">
							<input type="hidden" name="vipPrice_chess${status.index}"  id="vipPrice_chess${status.index}" value="${chess.vipPrice}">
						</td>
					</tr>
					</c:forEach>
					</c:if>
					
					<c:if test="${fn:length(otherList) >= 0}">
					<c:forEach var="other" items="${otherList}" varStatus="status">
						<tr>
						<td style="border: 1px solid #7F9DB9;">${other.tokenNo}</td>
						<td style="border: 1px solid #7F9DB9;">${other.roomNo}</td>
						<td style="border: 1px solid #7F9DB9;">${other.productName}</td>
						<td style="border: 1px solid #7F9DB9;">${other.unit}</td>
						<td style="border: 1px solid #7F9DB9;">${other.qty}</td>
						<td style="border: 1px solid #7F9DB9;">
							<c:choose>
								<c:when test="${other.if_able_discount == able and other.status != 'cancel'}">
									<input type="text" name="discountRange_other${status.index}" size="3" id="discountRange_other${status.index}" value="100" 
											class="easyui-numberbox" readonly data-options="onChange:function(value){
												onDiscountCheck('other', ${status.index}, value, '${other.discount_range}');
											}"/>
									<input type="hidden" name="rangeHidden_other${status.index }" id="rangeHidden_other${status.index}" value="${other.discount_range}" />
								</c:when>
								<c:otherwise>100</c:otherwise>
							</c:choose>
						</td>						
						<td style="border: 1px solid #7F9DB9;">${qu:parsePrice(other.price)}</td>
						<td style="border: 1px solid #7F9DB9;">${qu:parsePrice(other.totalPrice)}</td>
						<td style="border: 1px solid #7F9DB9;">${qu:parsePrice(other.vipPrice)}</td>
						<td style="border: 1px solid #7F9DB9;"><span id="actual_other${status.index}">${qu:parsePrice(other.actualPrice)}</span></td>
						<td style="border: 1px solid #7F9DB9;">&nbsp;</td>
						<td style="border: 1px solid #7F9DB9;">${other.statusName}</td>
						<td style="border: 1px solid #7F9DB9;">&nbsp;</td>
						<td style="border: 1px solid #7F9DB9;">&nbsp;</td>
						<td style="border: 1px solid #7F9DB9;">
							<c:if test="${other.status != 'cancel' }">
								<c:if test="${other.if_able_gift == able}">
									<input type="checkbox" name="giveOtherBox${status.index}" id="giveOtherBox${status.index}" value="other_${status.index}" onchange="onGive('other', ${status.index}, this)"/>
								</c:if>
							</c:if>
						</td>
						<td style="border: 1px solid #7F9DB9;">
							<c:if test="${other.status != 'cancel' }">
								<c:if test="${other.if_able_discount == able}">
									<input type="checkbox" name="discountOtherBox${status.index}" id="discountOtherBox${status.index}" value="other_${status.index}" onchange="onDiscount('other', ${status.index}, this)"/>
								</c:if>
							</c:if>
							<input type="hidden" name="id_other${status.index}"  id="id_other${status.index}" value="${other.id}">
							<input type="hidden" name="actualPrice_other${status.index}"  id="actualPrice_other${status.index}" value="${other.actualPrice}">
							<input type="hidden" name="totalPrice_other${status.index}"  id="totalPrice_other${status.index}" value="${other.totalPrice}">
							<input type="hidden" name="vipPrice_other${status.index}"  id="vipPrice_other${status.index}" value="${other.totalPrice}">
						</td>
					</tr>
					</c:forEach>
					</c:if>
				</table>
			</fieldset>			
		</div>
		
		<!-- 密码授权DIV -->
		<div id="passwordDiv" style="display: none;">
      		<table width="100%" style="margin-top: 20px;" border="0" align="center" cellpadding="4" cellspacing="4" bordercolor="#666666">
        		<tr>
          			<td width="80" align="right">授权帐号：</td>
          			<td><input type="password" id="operateAccount" name="operateAccount"/></td>
          		</tr>
          		<tr>
          			<td width="80" align="right">授权密码：</td>
          			<td><input type="password" id="operatePass" name="operatePass"/></td>
        		</tr>
      		</table>
    	</div>
    	
    	<input type="hidden" name="billingIds" id="billingIds" value="${billingIds}" /><!-- 帐单ID -->
    	<input type="hidden" name="serviceSize" id="serviceSize" value="${fn:length(serviceList)}" />
    	<input type="hidden" name="chessSize" id="chessSize" value="${fn:length(chessList)}" />
    	<input type="hidden" name="otherSize" id="otherSize" value="${fn:length(otherList)}" />
	</body>
</html>